package com.obas.model.intermediate.editor;

import java.lang.reflect.InvocationTargetException;
import java.util.Properties;

import org.apache.commons.beanutils.BeanUtils;
import org.springframework.util.StringUtils;

import com.ease.common.vo.editor.AbstractObjectEditor;
import com.obas.model.intermediate.BindAttr;

public class BindAttrEditor extends AbstractObjectEditor<BindAttr> {

	public BindAttr editAsText(String text) {

		String[] attrs = StringUtils.delimitedListToStringArray(text, "||", ",");
		Properties properties = StringUtils.splitArrayElementsIntoProperties(attrs, "=");
		BindAttr bindAttrObject = new BindAttr();
		try {
			BeanUtils.populate(bindAttrObject, properties);
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}

		return bindAttrObject;
	}

}
